<?php

class PresaleskuController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

	public function indexAction()
	{
		$req = $this->getRequest();
		if($req->isPost()){
			$auth = new Application_Model_Auth();
			if(!$auth->isLoggedIn()){
				echo '0';exit;
			}
			$rest = new Application_Model_Rest();
			//ajax $_POST值
			$shop_id = $req->getPost('shopid');
			$product_id = $req->getPost('product_id');
			$product_num = $req->getPost('product_num');
			//$acList  =  46:1012205,1
			$acList = $shop_id.':'.$product_id.','.$product_num;
			$res_postUserOrder = $rest->postUserOrder(0,$acList,'RShop',1003);
			if(!empty($res_postUserOrder)){
				$resObj = $res_postUserOrder[0];
				if(!empty($resObj)){
					$oid = $resObj->id;
					echo $oid;
					exit;
				}
			}
			echo 'error';
			exit;
		}

	}

    public function detailsAction()
    {
	   require_once 'LibWexinJssdk.php';
       $req = $this->getRequest();
	   if($req->isGet()){
		$id = $req->get('id');
		$rest = new Application_Model_Rest();
		$res = $rest->getUserPresaleProductDetails($id);
		if($res == false){
			$this->_redirect('/');
		}
		 //添加微信
		 $wecat = new LibWexinJssdk();
	     $wxDateInfo  = @$wecat->GetSignPackage();
		 $wxShareData = array(
			 'title'=>'我买了'.'“'.$res->price.'元 '.$res->skuname.'”',
			 'desc'=>$res->remark,
		   	 'image'=>$res->imgurl,
		 );
	     $wxDate = array_merge($wxDateInfo,$wxShareData);
	     $this->view->wxDate=$wxDate;
	     $this->view->res = $res;
	   }
    }
}





